<template>
  <div class="home-page">
    <el-container>
      <!-- 侧边栏 -->
      <el-aside width="200">
        <h1 class="logo">阿桂不贵</h1>
        <el-menu
          :default-active="$route.path"
          class="el-menu-vertical-demo"
          :router="true"
          :collapse="isCollapse"
        >
          <qf-sub-menu :sideMenu="menuList"></qf-sub-menu>
        </el-menu>
      </el-aside>
      <el-container>
        <!-- 顶部栏 -->
        <el-header>
          <el-row type="flex" class="row-bg" justify="space-between">
            <el-col :span="6">
              <div class="yincang grid-content">
                <i
                  :class="['iconfont' ,isCollapse?'icon-cebianlandanchu':'icon-cebianlanshousuo']"
                  @click="isCollapse = !isCollapse"></i>
              </div>
            </el-col>
            <el-col :span="6">
              <div class="grid-content">小桂管理系统</div>
            </el-col>
            <el-col :span="6">
              <div class="grid-content">
                <el-avatar :size="40" fit="fit" src="#"></el-avatar>
                <span>欢迎您：</span>
                <b class="nickname" @click="$router.push('/Mine');">{{ userInfo.nickname }}</b>
                <span class="quit" @click="quit">退出</span>
              </div>
            </el-col>
          </el-row>
        </el-header>
        <!-- 主题区域 -->
        <el-main>
          <!-- 面包屑 -->
          <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item
              :to="{ path: crumb.path }"
              v-for="(crumb,index) in crumbs"
              :key="index"
            >
              {{ crumb.meta.name }}
            </el-breadcrumb-item>
          </el-breadcrumb>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
// import { getLoginLog } from "@/api";
import { mapState } from "vuex"; //取值

export default {
  computed: {
    ...mapState(["userInfo", "menuList", "crumbs"]),
  },
  data() {
    return {
      isCollapse: false, //侧边菜单栏
    };
  },
  mounted() {
    // getLoginLog().then((res) => {
    //   console.log(res);
    // });
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    // 退出登入
    quit() {
      // 退出登入
      // 1、清除token 和 userInfo
      // 2、跳转到登入页

      localStorage.removeItem("login-token");
      localStorage.removeItem("user-Info");

      this.$router.push("/login");

      // 刷新页面
      window.location.reload();
    },
  },
};
</script>
<style scoped>
/* container样式 */
.el-header {
  background-color: #41b883;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-main {
  background-color: #fff;
  color: #333;
  text-align: center;
  line-height: 160px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

/* 侧边栏 */
.el-aside{
  background-color: #41b883;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}

.logo {
  height: 60px;
  background: linear-gradient(135deg, #4cb7ff, #41b883);
  /* background-image: url("../../assets/imgs/logo.png"); */
  background-size: 100%;
  background-repeat: no-repeat;
  background-position: center;
  color: #fff;
  line-height: 60px;
  text-align: center;
}

/* 顶部栏 */
.yincang{
  text-align: left;
}
.grid-content {
  border-radius: 4px;
  min-height: 60px;
  color: #fff;
}
.row-bg {
  background-color: #41b883;
}
.quit{
  color: #c64cff;
  margin-left: 10px;
}

/* 修改avatar 头像 的样式 */
.el-avatar.el-avatar--circle {
  vertical-align: middle;
  margin-right: 10px;
}
</style>
